package Demo;

import java.util.Scanner;

public class Demo03 {
    public static void main(String[] args) {
        /**
         * if语句 第二种写法:
         *         if(){
         *
         *         }else{
         *
         *         }
         * */

        Scanner s = new Scanner(System.in);

        System.out.println("请输入您的年龄");

        int age = s.nextInt();
        if(age >= 18){
            System.out.println("您已成年");
        }else{
            System.out.println("您未成年");
        }

        System.out.println("----------------------");
        /*
         * 键盘录入一个数，判断是奇数还是偶数
         * */

        Scanner sc = new Scanner(System.in);
        System.out.println("请您输入一个整数");
        int num = sc.nextInt();

        if(num % 2 ==0){
            System.out.println(num +"是偶数");
        }else{
            System.out.println(num +"是奇数");
        }

        //运用三目运算符

        String str = num % 2 ==0 ? num +"是偶数" : num +"是奇数";
        System.out.println(str);
    }
}
